package org.room402.model.chat;

import lombok.Builder;
import lombok.Data;
import org.room402.entity.chat.UserSession;
import org.springframework.web.reactive.socket.WebSocketSession;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Builder
public class UserInfoView {
    private String id;
    private String name;

    /**
     * 用户注册、上线时间
     */
    private LocalDateTime registerTime;

    /**
     * 头像地址
     */
    private String avatarUrl;


    public static UserInfoView form(UserSession userSession) {
        return UserInfoView.builder()
                .id(userSession.getId())
                .name(userSession.getName())
                .registerTime(userSession.getRegisterTime())
                .avatarUrl(userSession.getAvatarUrl())
                .build();
    }
}
